package com.refinement.controller;


import lombok.SneakyThrows;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Test extends Thread {


    @Override
    public void run() {
        System.out.println("monkey老师");
        System.gc();
    }

    public static void main(String[] args) {
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(10, 20,
                0L, TimeUnit.MILLISECONDS,
                new ArrayBlockingQueue<>(10));
        for (int i = 1; i <= 100; i++) {
            threadPoolExecutor.execute(new Task(i));
        }
    }
}

class Task implements Runnable {

    private final int i;

    public Task(int i) {
        this.i = i;
    }

    @SneakyThrows
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName() + "--" + i);
        Thread.sleep(2000L);
    }
}
